package Final;

import java.util.*;

public class test06 {

    /*covnertStringToList函数代码*/
    private static List<String> convertStringToList(String s) {
        List<String> list = new ArrayList<>();
        String[] split = s.split("\\s{1,}");
        list.addAll(Arrays.asList(split));
        return list;
    }

    /*remove函数代码*/
    private static void remove(List<String> list, String word) {
        list.removeAll(Collections.singleton(word));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list, word);
            System.out.println(list);
        }
        sc.close();
    }
}
